#!/bin/bash
# Set up a new SSH Server
# Author: liujin

# 安装 openssh 服务器端
sudo apt install -y openssh-server

# 启动 openssh 服务
service ssh start

# 设置开机自启动
sudo systemctl enable ssh

# 检查是否启动成功
echo ">>> You can run \"sudo systemctl status ssh\" to check if ssh is started."

# 输出 IP 地址
ip route

# 添加 ssh 公匙
echo ">>> 添加 SSH 公匙 "
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
mkdir -p "$HOME/.ssh"
cat "${SCRIPT_PATH}/../dotfiles/ssh/id_mpi.pub" >> "$HOME/.ssh/authorized_keys"
